package com.example.cofeed.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.blankj.utilcode.util.ActivityUtils;
import com.example.cofeed.R;
import com.example.cofeed.activity.fragment.TabFreeSubscriptionFragment;
import com.example.cofeed.activity.fragment.TabPaySubscriptionFragment;
import com.example.cofeed.adapter.PagerAdapter;
import com.example.cofeed.base.BaseActivity;
import com.flyco.tablayout.SlidingTabLayout;
import com.umeng.analytics.MobclickAgent;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OnLineSubscibeActivity extends BaseActivity {

    @BindView(R.id.tabs)
    SlidingTabLayout mTabs;
    @BindView(R.id.view_pager)
    ViewPager mViewPager;
    @BindView(R.id.iv_cart)
    ImageView mIvCart;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_on_line_subscibe;
    }

    @Override
    protected void init(Bundle savedInstanceState, View container) {
        setMainTitle("在线订阅");
        List<Fragment> fragments = new ArrayList<>();

        TabPaySubscriptionFragment tabPaySubscriptionFragment = new TabPaySubscriptionFragment();
        TabFreeSubscriptionFragment tabFreeSubscriptionFragment = new TabFreeSubscriptionFragment();

        fragments.add(tabPaySubscriptionFragment);
        fragments.add(tabFreeSubscriptionFragment);

        List<String> titles = new ArrayList<>();
        titles.add("付费订阅");
        titles.add("免费订阅");
        PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), fragments, titles);
        mViewPager.setAdapter(adapter);
        mTabs.setViewPager(mViewPager);

    }

    @OnClick(R.id.iv_cart)
    public void onViewClicked() {
        ActivityUtils.startActivity(CartActivity.class);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
    }

}
